#include "SensorXYZ.h"

void SensorXYZ::init()
{
	Serial.println("acc initializing...");

    controller->init();
	view->init();

	initStatus = true;
	Serial.println("acc initialized...");
}

void SensorXYZ::active()
{
	Serial.println("acc active...");
	isSuspend = false;
	i2cEventLoopService.addTask([&](void) {
		accService.configAccDataStreamMode(CONTINUOUS_MEASURE);
	});
	view->show();
	controller->active();
}

void SensorXYZ::suspend()
{
	Serial.println("acc suspend...");
	i2cEventLoopService.addTask([&](void) {
		accService.configAccDataStreamMode(UNUSED_MODE);
	});
	isSuspend = true;
	controller->suspend();
}

void SensorXYZ::execute()
{
	if (!isSuspend)
	{
		// nothing to do
		i2cEventLoopService.addTask([&](void) {
			accService.updateAcc();
		});
	}
}